/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 玩家展示信息(较多复用)
	/// module : structs
	/// </summary>
	public class PlayerShowPOD : IPOD 
    {
        public readonly static Func<PlayerShowPOD> FACTORY = () => new PlayerShowPOD();
		public static Func<PlayerShowPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public PlayerSimplePOD simplePOD;
		
		
		
		/*-- constructors --*/
		public PlayerShowPOD() {}
		public PlayerShowPOD(PlayerSimplePOD simplePOD) {
			this.simplePOD = simplePOD;
		}
		  public void Serial(SOutputStream _out) {
                if(simplePOD != default) {
                    _out.WriteByte(1);
                    _out.Write_pod(simplePOD);
                }
        }
            
        public void UnSerial(SInputStream _in) {
            while (_in.HasRemaining())
            {
                int _key = _in.ReadByte();
                switch (_key)
                {
                    case 1:
                        simplePOD = _in.Read_pod<PlayerSimplePOD>(PlayerSimplePOD.DynamicFactory);
                        break;
                    default: _in.SkipBinary();break;
                }
            }
        }
		
		public PlayerShowPOD Clone() {
            PlayerShowPOD o = DynamicFactory();
            if (simplePOD != null) {
                o.simplePOD = simplePOD.Clone();
            }
            return o;
        }
        
        public void Clear() {
            simplePOD = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "PlayerShowPOD [";
			str += "simplePOD=";
			str += simplePOD;
			str += "]";
			return str;
		}
		
	}
}